\section{XML Driving Directions}

\begin{quote}
Design an XML language to represent driving directions. For an example of a driving direction, 
see EX/driving.txt. There are countless different solutions, but try to make a finegrained model. 
Convert EX/driving.txt to fit into your new XML language. 
\end{quote}

\subsection{Driving Direction Markup Language}

We will now describe the design of an XML specified for representing driving directions, which we can call the directionML. 

The root element is \texttt{drivingDirection}, which contains a \texttt{start} element, an \texttt{end} element, a \texttt{totalEstTime} element, a \texttt{totalEstDistance} element and a sequence of \texttt{directionPoint} elements. 

The \texttt{start} element and \texttt{end} element contain attributes \texttt{address}, \texttt{state}, \texttt{zip} and \texttt{country}, the \texttt{totalEstTime} element contains attributes \texttt{hours} and \texttt{minutes} and the \texttt{totalEstDistance} contains an attribute \texttt{length}, which are all character data. The contents of these attributes are all straightforward.

A \texttt{directionPoint} element describes a point of the driving direction and contains a \texttt{length} character data attribute and a sequence of informal elements. Each element describes a component of the \texttt{directionPoint} such as <turnLeftOnto>, <via> or <towards>. The elements contain a text node with an absolute description such as '1600 Pennsylvania Ave Nw' or 'Exit 1'. 

\subsection{Convertion of EX/driving.txt}

Hereby follows a convertion of the code of EX/driving.txt fit into our new directionML. Only some of the points of directions are included since the informations are pretty redundant.

\begin{lstlisting}
<?xml version="1.0"?>
<drivingDirection xmlns="http://www.daimi.au.dk/dWebTek/directionML" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.daimi.au.dk/dWebTek/directionML directionML.xsd">
  <start address="W Mahoning St" state="Punxsutawney" 
    zip="PA 15767" country="US"/>
  <end address="1600 Pennsylvania Ave Nw" state="Washington" 
    zip="DC" country="US"/>
  <totalEstTime hours="4" minutes="33"/>
  <totalEstDistance length="246.68"/>
  <directionPoint length="0.1">
    <startOutGoing>NORTHWEST</startOutGoing>
    <on>PA-36</on>
    <on>N MAIN ST</on>
    <toward>LINCOLN AVE</toward>
  </directionPoint>
  <directionPoint length="0.2">
    <turnLeftOnto>LINCOLN AVE</turnLeftOnto>
  </directionPoint>
  <directionPoint length="1.7">
    <becomes>
      <before>LINCOLN AVE</before>
      <after>PA-436</after>
    </becomes>
  </directionPoint>
  <directionPoint length="27.9">
    <turnRightOnto>US-119 S</turnRightOnto>
    <turnRightOnto>BUFFALO-PITTSBURGH HWY</turnRightOnto>
  </directionPoint>
  <directionPoint length="27.7">
    <mergeOnto>US-422 E</mergeOnto>
    <via>EXIT A</via>
    <toward>EBENSBURG</toward>
  </directionPoint>
  <directionPoint length="0.1">
    <turnLeftOnto>ramp</turnLeftOnto>
  </directionPoint>
  <directionPoint length="17.1">
    <mergeOnto>US-22 E</mergeOnto>
    <mergeOnto>WILLIAM PENN HWY</mergeOnto>
  </directionPoint>
  <directionPoint length="27.6">
    <mergeOnto>I-99 S</mergeOnto>
    <mergeOnto>US-220 S</mergeOnto>
    <toward>BEDFORD</toward>
  </directionPoint>
  <directionPoint length="0.9">
    <takeThe>
      <exit>EXIT 1</exit>
      <toward>I-70</toward>
      <toward>PENNSYLVANIA TURNPIKE</toward>
      <toward>I-76</toward>
      <toward>BEDFORD</toward>
    </takeThe>
  </directionPoint>
  <directionPoint length="0.2">
    <turnSlightRightOnto>US-220 BR</turnSlightRightOnto>
  </directionPoint>
  <directionPoint length="0.2">
    <takeThe>
      <ramp/>
      <toward>ROCK CREEK PARKWAY</toward>
    </takeThe>
  </directionPoint>
  <directionPoint length="0.1">
    <takeThe>
      <exit>I-66 W / E ST</exit>
      <toward>JF KENNEDY CENTER</toward>
    </takeThe>
  </directionPoint>
  <directionPoint length="0.2">
    <takeThe>
      <exit>E STREET</exit>
      <onThe>left</onThe>
    </takeThe>
  </directionPoint>
</drivingDirection>
\end{lstlisting}